#include <cstdlib>
#include <iostream>
#include <string>
#include <boost/asio.hpp>

using boost::asio::ip::tcp;

int main(int argc, char *argv[])
{
    if (argc != 3) {
        std::cout << "usage: "<< argv[0] << " <address> <port>" << std::endl;;
        return -1;
    };
    
    tcp::iostream stream(argv[1], argv[2]);

    std::string buf;
    if (!stream) {       
        std::cerr << "failed to connect to server" << std::endl;
        return -1;
    }

    stream.unsetf(std::ios::skipws);
    while (!std::cin.eof() && std::getline(std::cin, buf)) {
        stream << buf << "\r\n" << std::flush;
        std::getline(stream, buf);
        std::cout << buf << std::endl;
    };

    return 0;
};
